package cn.lanqiao.ui;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.Font;
import javax.swing.JDesktopPane;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.beans.PropertyVetoException;
import java.awt.event.ActionEvent;

public class ForeignFrm extends JFrame {

	private static final long serialVersionUID = 1L;
	private JDesktopPane desktopPane;
	private JMenuBar menuBar ;
	private JMenu mnMenu1 ;
	private JMenuItem mntmSynopsis;
	private JMenuItem mntmCollege;
	private JMenu mnMenu2 ;
	private JMenuItem mntmTeam;
	private JMenuItem mntmTeacher;
	

	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ForeignFrm frame = new ForeignFrm();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	public ForeignFrm() {
		setTitle("校史校情");
		setBounds(100, 100, 1100, 900);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		//窗体居中
		setLocationRelativeTo(null);
		
		menuBar = new JMenuBar();
		menuBar.setBackground(new Color(255, 255, 240));
		setJMenuBar(menuBar);
		
		mnMenu1 = new JMenu("校情总览");
		mnMenu1.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		menuBar.add(mnMenu1);
		
		mntmSynopsis = new JMenuItem("学校简介");
		mntmSynopsis.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String title1 = "学校简介";
				JInternalFrame[] childFrms1 = desktopPane.getAllFrames();
				boolean isExists1 = false ;
				for(JInternalFrame f : childFrms1 ) {
					if( f.getTitle().equals(title1) ) {
						try {
							f.setSelected(true);
							isExists1 = true ;
						} catch (PropertyVetoException e1) {
							e1.printStackTrace();
						}
						break ;
					}
				}
				if( !isExists1 ) {
					SchProfileFrm sch = new SchProfileFrm();
					sch.setVisible(true);
					desktopPane.add(sch);
				}
				
			}
		});
		mntmSynopsis.setBackground(new Color(255, 255, 240));
		mntmSynopsis.setFont(new Font("微软雅黑", Font.PLAIN, 18));
		mnMenu1.add(mntmSynopsis);
		
		mntmCollege = new JMenuItem("二级学院");
		mntmCollege.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String title1 = "二级学院";
				JInternalFrame[] childFrms1 = desktopPane.getAllFrames();
				boolean isExists1 = false ;
				for(JInternalFrame f : childFrms1 ) {
					if( f.getTitle().equals(title1) ) {
						try {
							f.setSelected(true);
							isExists1 = true ;
						} catch (PropertyVetoException e1) {
							e1.printStackTrace();
						}
						break ;
					}
				}
				if( !isExists1 ) {
					CollegeFrm col = new CollegeFrm();
					col.setVisible(true);
					desktopPane.add(col);
				}
				
			}
		});
		mntmCollege.setBackground(new Color(255, 255, 240));
		mntmCollege.setFont(new Font("微软雅黑", Font.PLAIN, 18));
		mnMenu1.add(mntmCollege);
		
		mnMenu2 = new JMenu("师资队伍");
		mnMenu2.setFont(new Font("微软雅黑", Font.PLAIN, 20));
		menuBar.add(mnMenu2);
		
		mntmTeam = new JMenuItem("教学团队");
		mntmTeam.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String title1 = "教学团队";
				JInternalFrame[] childFrms1 = desktopPane.getAllFrames();
				boolean isExists1 = false ;
				for(JInternalFrame f : childFrms1 ) {
					if( f.getTitle().equals(title1) ) {
						try {
							f.setSelected(true);
							isExists1 = true ;
						} catch (PropertyVetoException e1) {
							e1.printStackTrace();
						}
						break ;
					}
				}
				if( !isExists1 ) {
					TeamFrm tea = new TeamFrm();
					tea.setVisible(true);
					desktopPane.add(tea);
				}
				
			}
		});
		mntmTeam.setBackground(new Color(255, 255, 240));
		mntmTeam.setFont(new Font("微软雅黑", Font.PLAIN, 18));
		mnMenu2.add(mntmTeam);
		
		mntmTeacher = new JMenuItem("教学名师");
		mntmTeacher.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String title1 = "教学名师";
				JInternalFrame[] childFrms1 = desktopPane.getAllFrames();
				boolean isExists1 = false ;
				for(JInternalFrame f : childFrms1 ) {
					if( f.getTitle().equals(title1) ) {
						try {
							f.setSelected(true);
							isExists1 = true ;
						} catch (PropertyVetoException e1) {
							e1.printStackTrace();
						}
						break ;
					}
				}
				if( !isExists1 ) {
					FamousTeaFrm fam = new FamousTeaFrm();
					fam.setVisible(true);
					desktopPane.add(fam);
				}
			
			}
		});
		mntmTeacher.setBackground(new Color(255, 255, 240));
		mntmTeacher.setFont(new Font("微软雅黑", Font.PLAIN, 18));
		mnMenu2.add(mntmTeacher);
		
		desktopPane = new JDesktopPane();
		desktopPane.setBackground(new Color(255, 255, 240));
		getContentPane().add(desktopPane, BorderLayout.CENTER);
	}

}
